<template>
	<view class="container">
		<view class="head">
			<view class="head-top" style="justify-content: center;">
				<view class="">更新信息</view>
			</view>
			<view class="head-txt">
				<u--form labelPosition="left" :model="uForm" ref="uForm" labelWidth='170rpx'>
					<u-form-item label="学生姓名:">
						<u--input v-model="uForm.name" disabled></u--input>
					</u-form-item>
					<u-form-item label="学生性别:">
						<u-radio-group v-model="uForm.sex" placement="row">
							<u-radio :customStyle="{marginRight: '20rpx'}" v-for="(item, index) in radiolist1"
								:key="index" :label="item.name" :name="item.name" @change="radioChange">
							</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="学生学号:">
						<u--input v-model="uForm.code" disabled></u--input>
					</u-form-item>
					<u-form-item label="监护人电话:">
						<u--input v-model="uForm.phone"></u--input>
					</u-form-item>
					<u-form-item label="学生班级:">
						<u--input v-model="uForm.classes_name" disabled></u--input>
					</u-form-item>
				</u--form>
			</view>
		</view>
		<view class="btn">
			<u-button type="primary" text="保存" @click="submit"></u-button>
		</view>
	</view>
</template>

<script>
	import {
		studentupdate
	} from '@/api/student.js'
	export default {
		data() {
			return {
				// 基本案列数据
				radiolist1: [{
						name: '男',
						disabled: false
					},
					{
						name: '女',
						disabled: false
					}
				],
				radiovalue1: '男',
				uForm: {},
			}
		},
		onLoad(e) {
			this.uForm = JSON.parse(e.obj)
		},
		methods: {
			radioChange(n) {
				this.uForm.sex = n
			},
			async submit() {
				let res = await studentupdate({
					...this.uForm,
				})
				if (res.code == 200) {
					uni.$u.toast(res.msg);
					setTimeout(() => {
						uni.reLaunch({
							url: "/pages/index/index"
						})
					}, 1000)

				} else {
					uni.$u.toast(res.msg);
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		width: 100vw;
		height: 100%;
		padding: 0 20rpx;
		box-sizing: border-box;

		.btn {
			margin: 0 auto;
			margin-top: 50rpx;
			width: 20%;

		}

		.head {
			width: 100%;
			border-radius: 20rpx;
			box-shadow: 5rpx 5rpx 10rpx 1px rgba(0, 0, 0, 0.3);

			.head-txt {
				width: 100%;
				padding: 40rpx;
				box-sizing: border-box;
				background-color: #fff;
				border-bottom-left-radius: 20rpx;
				border-bottom-right-radius: 20rpx;
			}

			.head-top {
				width: 100%;
				border-top-left-radius: 20rpx;
				border-top-right-radius: 20rpx;
				height: 100rpx;
				background-color: #449bed;
				display: flex;
				align-items: center;
				padding: 0 40rpx;
				box-sizing: border-box;
				color: #fff;
				font-weight: bold;
			}
		}
	}
</style>